﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data.Sql;


namespace Login.DB
{
    class DBLogin
    {
        sqlConnection myConnection = new sqlConnection("user id=dmaa0213_4;" + "password=MaaGodt;server=balder.ucn.dk;" + "Trusted_Connection=yes;" + "database=dmaa0213_4;" + "connection timeout=15");
    
        try
    {
        myconnection.Open();
    }
    catch(Exception e)
{
    console.WriteLine(e.ToString());
}
    SqlCommand myCommand= new SqlCommand("INSERT INTO table (Column1, Column2) " + "Values ('string', 1)", myConnection);
                                    
    
    myCommand.ExcecuteNonQuery();

    try
{
    SqlDataReader myReader = null;
    SqlCommand    myCommand = new SqlCommand("select * from table",  myConnection);
                                            
    myReader = myCommand.ExecuteReader();
    while(myReader.Read())
    {
        Console.WriteLine(myReader["Column1"].ToString());
        Console.WriteLine(myReader["Column2"].ToString());
    }
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}
try
{
    myConnection.Close();
}
catch(Exception e)
{
    Console.WriteLine(e.ToString());
}
}
}
